import requestUtil from "@/utils/requestUtil";
import { IObject } from "@/api/common/common";

const INVENTORY_STAT_BASE_URL = "/business/inventoryStat";

const InventoryStatAPI = {
  /** 获取入库数据 */
  statInChart(queryParams: InventoryStatQuery) {
    queryParams.startDay = queryParams?.queryTime?.[0];
    queryParams.endDay = queryParams?.queryTime?.[1];
    return requestUtil.get<BaseChart>(
      `${INVENTORY_STAT_BASE_URL}/statInChart`,
      queryParams
    );
  },

  /** 获取出库数据 */
  statOutChart(queryParams: InventoryStatQuery) {
    queryParams.startDay = queryParams?.queryTime?.[0];
    queryParams.endDay = queryParams?.queryTime?.[1];
    return requestUtil.get<BaseChart>(
      `${INVENTORY_STAT_BASE_URL}/statOutChart`,
      queryParams
    );
  },

};

export default InventoryStatAPI;


export interface ChartOptions {
  tooltip: any;
  legend: any;
  grid: any;
  xAxis: any;
  yAxis: any;
  series: Array<{
    name: string;
    type: string;
    data: any[];
    smooth: boolean;
  }>;
}

/** 分页查询参数 */
export interface InventoryStatQuery  {
  /** 搜索关键字 */
  warehouseId?: string;
  operations?: Array<string>;
  /** 操作时间 */
  queryTime?: [string, string];
  startDay?: string;
  endDay?: string;
  in?: boolean;
}


export interface BaseChart {
  /** ID */
  axis: Array<string>;
  series: Array<ChartData>;
  type: string;
  
}


export interface ChartData {
  name: string;
  data: Array<string>;
  type: string;
  
}



export enum InventoryType {
  MAIN = "MAIN",
  SUB = "SUB",
  INSTRUMENT = "INSTRUMENT",
  OTHER = "OTHER",
  SALE_MEAL = "SALE_MEAL",
}

export const Inventory_LABEL: IObject = {
  [InventoryType.MAIN]: "主材",
  [InventoryType.SUB]: "辅材",
  [InventoryType.INSTRUMENT]: "器具",
  [InventoryType.OTHER]: "其他",
  [InventoryType.SALE_MEAL]: "套餐",
};
